import axios from 'axios'

const serve = axios.create({
    baseURL: 'http://127.0.0.1:3000',
    timeout: 10000
}) 

serve.interceptors.request.use(config => {
    let data = JSON.parse(localStorage.getItem('vuex')) 
    if(data) {
        config.headers.token = data.token || ''
    }
    return config
}, err => {
    throw err
})



serve.interceptors.response.use(res => {
    return res.data
}, err => {
    throw err
})

export default serve